package com.loanapp.server.market.provider.modular.customer.api.impl;

import com.github.pagehelper.PageInfo;
import com.loanapp.server.market.api.customer.api.CustomerBorrowInfoApi;
import com.loanapp.server.market.api.customer.entity.CustomerBorrowInfo;
import com.loanapp.server.market.api.customer.query.CustomerBorrowInfoQuery;
import com.loanapp.server.market.provider.modular.customer.service.CustomerBorrowInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(CustomerBorrowInfoApi.mapping)
public class CustomerBorrowInfoApiImpl implements CustomerBorrowInfoApi {

    @Autowired
    private CustomerBorrowInfoService service;

    @PostMapping
    public Long InsertCustomerBorrowInfo(@RequestBody CustomerBorrowInfo customerBorrowInfo) throws Exception {
        return service.Insert(customerBorrowInfo);
    }

    @PostMapping
    public CustomerBorrowInfo selectOne(@RequestParam Long Biid) throws Exception {
        return selectOne(Biid);
    }

    @PostMapping
    public PageInfo<Map<String, Object>> getBorrowInfoListPage(@RequestBody CustomerBorrowInfoQuery query) throws Exception {
        return service.getBorrowInfoListPage(query,query.getPageParams());
    }

    @PostMapping
    public List<Map<String, Object>> getApplyListPage(@RequestBody int[] page,@RequestParam Long user) {
        return service.getApplyListPage(page,user);
    }

    @PostMapping
    public void insertApplyRecord(@RequestParam Long user,@RequestParam Long productId) {
           service.insertApplyRecord(user,productId);
    }
}
